﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Graphics;

namespace Cobalt.Content.Pipeline.Graphics.Illumination
{
	public class LitMaterialContent : MaterialContent
	{
		public bool CastsShadows
		{
			get { return OpaqueData.GetValue( "CastsShadows", true ); }
			set { OpaqueData["CastsShadows"] = value; }
		}

		public bool IsTransparent
		{
			get { return OpaqueData.GetValue( "IsTransparent", false ); }
			set { OpaqueData["IsTransparent"] = value; }
		}

		public bool IsLightmapped
		{
			get { return OpaqueData.GetValue( "IsLightmapped", true ); }
			set { OpaqueData["IsLightmapped"] = value; }
		}

		public ExternalReference<TextureContent> DiffuseTexture
		{
			get
			{
				ExternalReference<TextureContent> ret;
				if( Textures.TryGetValue( "Diffuse", out ret ) && !string.IsNullOrEmpty( ret.Filename ) )
					return ret;

				return null;
			}
			set
			{
				if( value != null && string.IsNullOrEmpty( value.Filename ) )
					value = null;

				if( value == null )
					Textures.Remove( "Diffuse" );
				else
					Textures["Diffuse"] = value;
			}
		}
		public Vector4 DiffuseColor
		{
			get { return OpaqueData.GetValue( "DiffuseColor", Vector4.One ); }
			set { OpaqueData["DiffuseColor"] = value; }
		}

		public ExternalReference<TextureContent> EmissiveTexture
		{
			get
			{
				ExternalReference<TextureContent> ret;
				if( Textures.TryGetValue( "Emissive", out ret ) && !string.IsNullOrEmpty( ret.Filename ) )
					return ret;

				return null;
			}
			set
			{
				if( value != null && string.IsNullOrEmpty( value.Filename ) )
					value = null;

				if( value == null )
					Textures.Remove( "Emissive" );
				else
					Textures["Emissive"] = value;
			}
		}
		public Vector4 EmissiveColor
		{
			get { return OpaqueData.GetValue( "EmissiveColor", Vector4.Zero ); }
			set { OpaqueData["EmissiveColor"] = value; }
		}
	}
}
